<?php
class MainController extends AppController {

    public $layout = 'main';

    function beforeFilter() {
        parent::beforeFilter(); 
        $this->loadModel('ProductClasse');
        $this->loadModel('Product');
        $product=$this->Product->find("all",array('limit'=>9,'order'=>array('id' =>'desc')));
        $productclass=$this->ProductClasse->find("all",array());  
        if(!empty($id)){
            $cates = $this->Product->find('all',array('conditions'=>array('class'=>$id),'limit'=>9,'order'=>array('id' =>'desc')));
            
        }else{
            $cates = $this->Product->find('all',array('limit'=>9,'order'=>array('id' =>'desc')));
        }
        $this->set("product",$product); 
        $this->set("productclass",$productclass); 
        $this->set('pro',$cates); 
    }

    function index($id=null){   
    	$id = $this->rm_end_html($id);
	    $this->loadModel('News');
        $newd=$this->News->find("all",array('limit'=>7,'order'=>array('id' =>'desc')));
        $newa=$this->News->find("all",array('limit'=>7,'order'=>array('id' =>'asc')));
        $this->set('newd',$newd); 
        $this->set('newa',$newa); 
    }

}